package com.by.picture.demos.service.impl;

/**
 * @version 1.0
 * @Author 彭彦彬
 * @Date 2025/4/7 19:34
 * @注释
 */
import com.by.picture.demos.dao.ImageStorageRepository;
import com.by.picture.demos.pojo.ImageStorage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

@Service
public class ImageStorageService {

    @Autowired
    private ImageStorageRepository imageStorageRepository;

    public void saveImageInfo(String fileName, String originalFileName, String filePath, long fileSize, String fileType, String uploadedBy) {
        ImageStorage imageStorage = new ImageStorage();
        imageStorage.setFileName(fileName);
        imageStorage.setOriginalFileName(originalFileName);
        imageStorage.setFilePath(filePath);
        imageStorage.setFileSize(fileSize);
        imageStorage.setFileType(fileType);
        imageStorage.setUploadTime(LocalDateTime.now());
        imageStorage.setUploadedBy(uploadedBy);
        imageStorage.setStatus(1); // 正常状态

        imageStorageRepository.save(imageStorage);
    }
}